package br.org.mestrado.vais;

import java.util.Comparator;

public class ParetoComparator implements Comparator<Anticorpo> {

	private final int NUM_OBJECTIVES;

	public ParetoComparator(final int c) {
		NUM_OBJECTIVES = c;
	}

	@Override
	public int compare(Anticorpo o1, Anticorpo o2) {

		int less_than = 0;

		for (int pointer = 0; pointer < NUM_OBJECTIVES; pointer++) {

			if (o1.getObjectives()[pointer] < o2.getObjectives()[pointer])
				less_than++;

		}

		if (less_than > (float) NUM_OBJECTIVES / 2)
			return -1;
		else if (less_than < (float) NUM_OBJECTIVES / 2)
			return 1;

		return 0;
	}

}
